<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSVToArray</title>
</head>

<body>
    <p id="res"></p>
    <script>
        const CSVToArray = (str, delimiter = ',', omitFirstRow = false) => {
            return str.slice(omitFirstRow ? str.indexOf('\n') + 1 : 0).split('\n').map(v => v.split(delimiter));
        }
        const res = document.getElementById('res');
        res.innerHTML = `CSVToArray('a,b\nc,d');的结果是:${JSON.stringify(CSVToArray('a,b\nc,d'))}`;
    </script>
</body>

</html>